<html>
<head><meta charset="utf-8"><title>How important is the LLVM Data Layout stack value? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html">How important is the LLVM Data Layout stack value?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204079625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204079625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204079625">(Jul 16 2020 at 13:04)</a>:</h4>
<p>Since the PSP now has a target entry within rust, of course I need to make one for the GBA. Have to keep up those friendly rivalries.</p>
<p>I've used <code>cargo-xbuild</code> with a target.json file before and the rustc target type is essentially the same thing, so i'm not really lost there, except for the LLVM Data Layout string. The LLVM docs for what element means what make sense overall, but my question is: how much does the stack alignment matter? By default the data layout makes the stack 64-bit aligned, and in the GNU "eabi" convention the stack is also 64-bit aligned, but the device itself is only a 32-bit device, so nothing at all actually needs to be 64-bit aligned in terms of the hardware.</p>
<p>Will it just work to just say <code>S32</code> in the data layout?</p>
<p>My only real concern is that the stack memory is relatively limited (32k), so I don't want to go burning a bunch of extra memory keeping the stack 64-bit aligned for no reason.</p>



<a name="204082927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204082927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204082927">(Jul 16 2020 at 13:28)</a>:</h4>
<p>If you have any ffi with code from other toolchains, then they do need to agree on this.</p>



<a name="204083017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204083017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204083017">(Jul 16 2020 at 13:28)</a>:</h4>
<p>Pretty sure you get a hard error if your layout mismatches from what LLVM says it should be. </p>
<p>I never figured why we have to put it in both rustc and llvm though.</p>



<a name="204083278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204083278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204083278">(Jul 16 2020 at 13:30)</a>:</h4>
<p>If it is only put in LLVM, rustc would have to somehow request it from LLVM for the layout computation.</p>



<a name="204083409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204083409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204083409">(Jul 16 2020 at 13:31)</a>:</h4>
<p>But we always have LLVM available /s <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="204083539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204083539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204083539">(Jul 16 2020 at 13:32)</a>:</h4>
<p>I guess that’s an error that occurs after layout computation then.</p>



<a name="204083920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204083920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204083920">(Jul 16 2020 at 13:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F/near/204083409">said</a>:</p>
<blockquote>
<p>But we always have LLVM available /s <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>
</blockquote>
<p>Not for long if I can do something about it :)</p>



<a name="204084418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204084418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204084418">(Jul 16 2020 at 13:39)</a>:</h4>
<p>Wait what? Are y'all sure that we must repeat the same string that's already in LLVM? Then why can't codegen just read it from LLVM?</p>



<a name="204084700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204084700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204084700">(Jul 16 2020 at 13:41)</a>:</h4>
<p>We need most of the information from the layout string pre-LLVM and even if we don't use LLVM for codegen at all (for type layout), so duplicating it allows us to be independent of LLVM in those respects and comparing it avoids subtle bugs</p>



<a name="204084849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204084849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204084849">(Jul 16 2020 at 13:42)</a>:</h4>
<p>Oh, okay. I didn't know rustc even consumes that.</p>



<a name="204090695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204090695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204090695">(Jul 16 2020 at 14:27)</a>:</h4>
<p>According to LLVM's docs, their "default data layout" string is just a default, and you can omit any entry in your provided string that matches the default value.</p>



<a name="204091155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204091155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204091155">(Jul 16 2020 at 14:30)</a>:</h4>
<p>Also, I'd like to ask if anyone knows: Does S64 means that the stack is 64-bit aligned always? or just on function entry? Because, again, this device doesn't even have 64-bit values, so if you push a register to the stack you'd be pushing a 32-bit value and then be off-aligned. Would there be a silent second push to get back to 64-bit, or would it only try to reattain 64-bit alignment if you then call another function from there?</p>



<a name="204091317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204091317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204091317">(Jul 16 2020 at 14:31)</a>:</h4>
<p>It would only be on function entry I think</p>



<a name="204092346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204092346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204092346">(Jul 16 2020 at 14:38)</a>:</h4>
<p>That's ultimately probably not so bad</p>



<a name="204092413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204092413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204092413">(Jul 16 2020 at 14:39)</a>:</h4>
<p>your call stack hopefully doesn't ever go so deep that an occasional word per call will be a big factor</p>



<a name="204092748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204092748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204092748">(Jul 16 2020 at 14:41)</a>:</h4>
<p>ah, yeah, it's "at public function entry", <a href="https://wiki.debian.org/ArmEabiPort#Stack_alignment">https://wiki.debian.org/ArmEabiPort#Stack_alignment</a></p>



<a name="204640226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640226">(Jul 22 2020 at 08:18)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> enjoy <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_target/abi/mod.rs#L16-L218">https://github.com/rust-lang/rust/blob/master/src/librustc_target/abi/mod.rs#L16-L218</a></p>



<a name="204640283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640283">(Jul 22 2020 at 08:18)</a>:</h4>
<p>the main thing we get from there that we have <em>nowhere else</em> is alignments for various types</p>



<a name="204640300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640300">(Jul 22 2020 at 08:18)</a>:</h4>
<p>oh and I guess we're still not.... oh we are!</p>



<a name="204640306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640306">(Jul 22 2020 at 08:18)</a>:</h4>
<p>so happy to see this <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_target/abi/mod.rs#L154-L174">https://github.com/rust-lang/rust/blob/master/src/librustc_target/abi/mod.rs#L154-L174</a></p>



<a name="204640322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640322">(Jul 22 2020 at 08:19)</a>:</h4>
<p>even if it means the target spec has redundancies :P</p>



<a name="204640427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20important%20is%20the%20LLVM%20Data%20Layout%20stack%20value%3F/near/204640427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20important.20is.20the.20LLVM.20Data.20Layout.20stack.20value.3F.html#204640427">(Jul 22 2020 at 08:20)</a>:</h4>
<p>(you'd think I'd remember that was there from the start, lol)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>